package com.hzncc.scaffold.mapper;

import com.hzncc.scaffold.entity.Other.Trainingprogram;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hzncc.scaffold.entity.Vo.TrainingprogramVo;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author DrunkBear
 * @since 2022-04-27
 */
@Component
public interface TrainingprogramMapper extends BaseMapper<Trainingprogram> {

    @Select("SELECT\n" +
            "\t`trainingprogram`.`id`,\n" +
            "\t`trainingprogram`.`title`,\n" +
            "\t`trainingprogram`.`cover`,\n" +
            "\t`trainingprogram`.`edPhase`,\n" +
            "\t`trainingprogram`.`stayAtTop`,\n" +
            "\t`trainingprogram`.`sortTime`,\n" +
            "\t`major`.`id` AS `majorId`,\n" +
            "\t`major`.`name` AS `majorName` \n" +
            "FROM\n" +
            "\t`trainingprogram` AS `trainingprogram`\n" +
            "\tLEFT OUTER JOIN `major` AS `major` ON `trainingprogram`.`majorId` = `major`.`id` \n" +
            "WHERE\n" +
            "\t`trainingprogram`.`status` = 1 \n" +
            "\tAND `trainingprogram`.`isDelete` = 0 \n" +
            "ORDER BY\n" +
            "\t`trainingprogram`.`stayAtTop` DESC,\n" +
            "\t`trainingprogram`.`sortTime` DESC")
    public List<TrainingprogramVo> selectTrainingList();
}
